<?php 
// wymagane w layout
echo $this->Section->main();
?>
<?php
echo $javascript->codeBlock("
	$(document).ready(function(){
		$(\".gallery a[rel^='prettyPhoto']\").prettyPhoto({animationSpeed:'slow',theme:'facebook',slideshow:8000,autoplay_slideshow:false,overlay_gallery:false});

	});		
",$options = array('allowCache'=>false,'safe'=>false,'inline'=>false));
?>
<?php 
$this->Html->styleBlock("
	div.gallery a.highslide { display: block; width: 113px; height: 150px; padding: 0px; margin: 3px;  border: solid 7px #fff; background-position: center; background-repeat: no-repeat; float: left; overflow: hidden;}
	div.gallery a.highslide:hover { padding: 0px; margin: 3px;  }
",array('inline'=>false));
?>

<div class="content">
	<div id="left-column">
		<?php echo $this->element('left_column')?>		
	</div>

	<div class="right-store-column search-bg">
		<?php echo $this->element('search_more',array('plugin'=>'store'))?>
	</div>
		
	<div class="right-store-column">						
		<div class="storeProducts view gallery">
		<h2><?php echo $storeProduct['StoreProduct']['name']; ?></h2>
			<dl><?php $i = 0; $class = ' class="altrow"';?>
				<dt<?php if ($i % 2 == 0) echo $class;?>>
					<div<?php if ($i++ % 2 == 0) echo $class;?>>
						<span class="view-cena-produktu"><?php echo __d('store','Cena: ',true)?></span>
					    <?php if($storeProduct['StoreProduct']['price_przecena'] > 0 && $storeProduct['StoreProduct']['price_promocja'] == 0){?>
								<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_przecena'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span> 
								<br/><span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange']);?></span> 
						<?php }else if( $storeProduct['StoreProduct']['price_promocja'] > 0){?>
								<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_promocja'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span> 
								<br/><span class="product-view-price-discount"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange']);?></span>
						<?php }else{?>
								<span class="product-view-price"><?php echo $this->Store->price($storeProduct['StoreProduct']['price_detaliczna'],2,'',null,$storeProduct['StoreProduct']['currency_id'],$storeProduct['StoreCurrency']['exchange'])?></span>
						<?php }?>	
						<br/><?php echo $storeProduct['StoreUnit']['name']?><br/>						
						
					</div>
					<div<?php if ($i++ % 2 == 0) echo $class;?>>					
						<?php echo $storeProduct['StoreModel']['name']; ?>		
						<?php $ilosc_typow = count($storeProduct['StoreType']);?>
						<?php if($ilosc_typow != 0){?>
						<?php echo $this->Form->create('StoreProduct',array('url'=>array('plugin'=>'store','controller'=>'carts','action'=>'cart_add')));?>
						<?php echo $this->Form->hidden('StoreProduct.id',array('value'=>$storeProduct['StoreProduct']['id']));?>
						<?php
						$j=0; 
						
						foreach ($storeProduct['StoreType'] as $type) {?>					
						<div<?php if ($j++ % 2 == 0) echo $class;?>>					
							<?php 
								if($ilosc_typow > 1){
									echo $this->Form->checkbox('StoreType.'.$type['id'].'.id',array('value'=>$type['id'],'style'=>'float: left;')); 
								}else{
									echo $this->Form->hidden('StoreType.'.$type['id'].'.id',array('value'=>$type['id'])); 
								}	
								echo $this->Form->hidden('StoreType.'.$type['id'].'.name',array('value'=>$type['name']));
								echo $this->Form->hidden('StoreType.'.$type['id'].'.amount',array('value'=>1));
								echo $type['name'];
							?>									
						</div>	
						<?php }?>	

						<?php 
							//echo $html->link(__d("store","Order Product",true), array('plugin'=>'store','controller'=>'products','action' => 'cart_add', $storeProduct['StoreProduct']['id']),	array('escape'=>false,'class'=>'button-order-prodyct')); 
					    ?>	
					    <?php echo $this->Form->end(__d("store","Order Product",true));?>	
					    <?php }else{?>
					    	<div class="clr"></div>	
					    	<br/>
					    	<div class="store-view-stan-zerowy"><?php echo __d('store','Dostepna ilosc: 0',true)?></div>							
						<?php }?>
									
					</div>
				</dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<a href="<?php echo $fileUpload->image($storeProduct['StoreUpload']['name'],array('autoResize'=>false,'imagePathOnly'=>true));?>" class="highslide" title="<?php echo $storeProduct['StoreProduct']['name']?>" rel="prettyPhoto[gallery]" style="background: #ffffff url(<?php echo str_replace(' ',"%20",$fileUpload->image($storeProduct['StoreUpload']['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>true)));?>) center no-repeat;"></a>
					<?php foreach ($storeProduct['StoreUpload'] as $key => $img) {
						if(is_array($img) && !empty($img)){?>
							<a href="<?php echo $fileUpload->image($img['name'],array('autoResize'=>false,'imagePathOnly'=>true));?>" class="highslide" title="<?php echo $storeProduct['StoreProduct']['name']?>" rel="prettyPhoto[gallery]" style="background: #ffffff url(<?php echo str_replace(' ',"%20",$fileUpload->image($img['name'],array('autoResize'=>true,'width'=>100,'imagePathOnly'=>true)));?>) center no-repeat;"></a>							
					<?php }}?>
					&nbsp;
				</dd>	
				
				
				<?php if(!empty($storeProduct['StoreProduct']['www'])){?>
				<div class="clr"></div>	
				<dt<?php if ($i % 2 == 0) echo $class;?>><?php __d('store','Www'); ?></dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $html->link(__d('store','Allegro',true),$storeProduct['StoreProduct']['www']) ?>
					&nbsp;
				</dd>
				<?php }?>
				
				<?php if(!empty($storeProduct['StoreProduct']['content'])){?>
				<div class="clr"></div>	
				<dt<?php if ($i % 2 == 0) echo $class;?>>
					&nbsp;
				</dt>
				<dd<?php if ($i++ % 2 == 0) echo $class;?>>
					<?php echo $storeProduct['StoreProduct']['content']; ?>
					&nbsp;
				</dd>
				<?php }?>
			</dl>
			<div class="clr"></div>
		</div>
		<div class="clr"></div>		
		<?php echo $this->Section->generate(1);?>
		<div class="clr"></div>
	</div>
	<div class="clr"></div>	

	<?php if($session->check('Auth.User.id')){?>
	<?php echo $this->element('toolbar_actions_main',array('plugin'=>'store','toolbar'=>'product'))?>
	<?php }?>
</div>
<div class="clr"></div>